<template>
	<view :class="{'my-tabs':true,'space-between':formatBe}">
		<view  v-for="(item,index) in getModelData" :key="index" :class="{'tab-item':true,'active':activeIndex==index}" @tap="tap(index)">
			{{item.label}}
		</view>
		<view class="more">
		<label>查看更多 </label>	
		<image src="../../static/nav/more.png" mode="更多" class="moreicon"></image>
		</view>
	</view>
</template>

<script>
	import MkGoodsList from '../mk-goods-list/mk-goods-list.vue'
	export default {
		components:{
			MkGoodsList
		},
		props:['modelData','initIndex'],
		data() {
			return {
				goods:[
					
					
						{
							img:'../../static/course/couse1.png',
							title:'深入理解C#',
							amount:'12',
							amountRemark:'没有过多理解',
							label:'测试',
							littleTitle:'C#你不知道得事情'
						},
						{
							img:'../../static/course/couse2.png',
							title:'深入理解C#',
							amount:'12',
							amountRemark:'没有过多理解',
							label:'测试',
							littleTitle:'C#你不知道得事情'
						},
						{
							img:'../../static/course/couse3.png',
							title:'深入理解C#',
							amount:'12',
							amountRemark:'没有过多理解',
							label:'测试',
							littleTitle:'C#你不知道得事情'
						},
						{
							img:'../../static/course/couse4.png',
							title:'深入理解C#',
							amount:'12',
							amountRemark:'没有过多理解',
							label:'测试',
							littleTitle:'C#你不知道得事情'
						}
						],
				defaultInfo:{
					data:[
						{label:"在线",},
						{label:"未开放"}
						// {label:"查看更多"},
					],
				},
				activeIndex:0,//默认索引
			}
		},
		computed:{
			getModelData(){
				return this.modelData||this.defaultInfo.data
			},
			formatBe(){
				return this.modelData
						?this.modelData.length>4?true:false
						:false
			}
		},
		methods: {
			tap(index){
				if(index!==this.activeIndex)this.$emit("change",index);
				this.activeIndex=index;
			},
			/**
			 * @name 初始化activeIndex
			 */
			initActive(){
				this.activeIndex=this.initIndex||this.activeIndex
			}
		},
		created() {
			this.initActive()
		},
		
		goodsItem(item, e) {
		    console.log(item);
		    console.log(e);
		}
	}
</script>
<style lang='scss'>
	page{
		
	}
	.my-tabs {
		height: 88upx;
		font-size: 28upx;
		display: flex;
		justify-content: space-around;
		box-sizing: border-box;
		border-top: 2upx solid #dddddd;
		border-bottom: 2upx solid #dddddd;
		min-width: 100%;
		overflow-x: auto;
		
		.tab-item{
			line-height: 48upx;
			padding: 20upx;
			min-width: 100upx;
			text-align: center;
		}
		.tab-item.active{
			position: relative;
			color: #3682FF;
		}
		.tab-item.active::after{
			content: "";
			position: absolute;
			bottom: 0;
			left:50%;
			transform: translateX(-50%);
			width: 100%;
			border-bottom: 4upx solid #3682FF;
			animation: test ease 1 1.5s;
		}
	}
	.my-tabs.space-between{
		justify-content: space-between;
	}
	.more{
		    text-align: center;
		    line-height: 2.5rem;
	}
	.more:hover{
		color: #007AFF;
	}
	.moreicon{
		width: 20rpx;
		height: 20rpx;		
		margin-left: 10upx;
	}
	@keyframes test{
		0%{width: 100%}
		50%{width: 150%}
		100%{width: 100%}
	}
</style>
